/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SplashFrame.java
 *
 * Created on 07-29-2011, 10:21:48 PM
 */

package Splash;

import javax.swing.JLabel;
import javax.swing.JProgressBar;

import com.sun.awt.AWTUtilities;


public class SplashFrame extends javax.swing.JFrame {

    //esta variable hace referencia a si misma
    private SplashFrame splashFrame = this;

    /** Creates new form SplashFrame */
    public SplashFrame() {
        //este metodo hace que el frame no tenga la barra de titulo
        //debe ser llamado antes de cargar los componentes de frame
        //en este caso antes del initComponents
        setUndecorated(true);
        initComponents();
        //hace la ventana transparente 1 es totalmente visible, 0 es totalmente invisible
       //AWTUtilities.setWindowOpacity(splashFrame, new Float(0.8));
        //centro el frame a la pantalla
        setLocationRelativeTo(null);
        startThread();
    }

    private void startThread(){
        Thread thread = new Thread(new Runnable() {

            public void run() {
                //se envia el frame del splash a la aplicacion que deseamos abrir
                AplicationFrame aplicationFrame = new AplicationFrame(splashFrame);
                //centro el frame
                aplicationFrame.setLocationRelativeTo(null);
                //hago el frame visible
                
                //cuando set termita de instanciar el AplicationFrame el SplashFrame se cierra
                dispose();
            }
        });
        thread.start();
    }

    public JProgressBar getProgressBar() {
        //este metodo nos permite obtener la barra de progreso desde el AplicationFrame
        return progressBar;
    }

    public JLabel getLabel() {
        //este metodo devuelve el label
        return label;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        label = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(102, 102, 102));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Feed&Fitness.jpg"))); // NOI18N

        label.setForeground(new java.awt.Color(51, 153, 255));
        label.setText("Loading Information");

        progressBar.setStringPainted(true);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(label))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel label;
    private javax.swing.JProgressBar progressBar;
    // End of variables declaration//GEN-END:variables

}
